import React from 'react';
import { Modal } from 'antd';
import Grid from '../../components/table/grid';
import { injectIntl } from 'react-intl';

class rechargeHis extends React.Component {
    constructor(props){
        super(props);
        this.state = {
            refresh:0
        };
        const common = this.props.intl.messages.common;
        this.columns = [
            {
                title: common.type,
                dataIndex: 'type',
                key: 'type',
            },
            {
                title: common.amount,
                dataIndex: 'amount',
                key: 'amount',
            },
            {
                title: common.time,
                dataIndex: 'createTime',
                key: 'createTime',
            },

        ];
    }
    transformData=(data)=>{
        const common = this.props.intl.messages.common;
        data.forEach((item)=>{
            if(item.type==1){
                item.type=common.rechargeByBackstage
            }
            if(item.type==2){
                item.type=common.refundByBackstage
            }
        });
        return data;
    }

    render() {
        const { visible, onCancel, account } = this.props;
        const common = this.props.intl.messages.common;

        return (
            <Modal
                wrapClassName="sass-tableWrapper"
                visible={visible}
                title={common.rechargeHis}
                onCancel={onCancel}
                footer={[<div key={1} style={{height:22}}></div>]}
            >
                <Grid transformData={this.transformData} refresh={Symbol('fresh')} params={{accountId:account?account.id:''}} columns={this.columns} url="api/user/rechargeLog/qry"/>
            </Modal>
        );
    }
}

export default injectIntl(rechargeHis)